//
//  YDBecomeBrokerController.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/1/30.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDBecomeBrokerController.h"
#import "YDSendBrokerInformationController.h"

@interface YDBecomeBrokerController ()

@property (nonatomic , weak) UIImageView *backImage;

//申请按钮
@property (nonatomic , weak) SYNoHeightedButton *brokerButton;

@end

@implementation YDBecomeBrokerController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.extendedLayoutIncludesOpaqueBars = YES;
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"经纪人申请";
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:DRJAlphaColor(255, 255, 255, 0.0)] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    [self backImage];
    [self brokerButton];
    
}
-(UIImageView *)backImage
{
    if (_backImage == nil) {
        UIImageView *backImage = [[UIImageView alloc] init];
        [self.view addSubview:backImage];
        backImage.contentMode = UIViewContentModeScaleAspectFit;
        if (isPhoneX) {
            backImage.image = [UIImage imageNamed:@"brokerImageX"];
        }else{
            backImage.image = [UIImage imageNamed:@"becomeBroker"];
        }
        [backImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.top.equalTo(self.view);
        }];
        _backImage = backImage;
    }
    return _backImage;
}

-(SYNoHeightedButton *)brokerButton
{
    if (_brokerButton == nil) {
        SYNoHeightedButton *brokerButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self.view addSubview:brokerButton];
        [brokerButton setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:blueyGrey]] forState:UIControlStateDisabled];
        [brokerButton setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:Orange]] forState:UIControlStateNormal];
        brokerButton.titleLabel.font = [UIFont systemFontOfSize:font16ScreenWRate * LKScreenW];
        brokerButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        [brokerButton setTitle:@"立即申请" forState:UIControlStateNormal];
        [brokerButton setTitle:@"正在审核" forState:UIControlStateDisabled];
        [brokerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [brokerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
        [brokerButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view);
            make.width.equalTo(@(rate375(248)));
            if (isPhoneX) {
                make.top.equalTo(self.view).offset(rateX812(539 + 88));
                make.height.equalTo(@(rateX812(48)));
            }else{
                make.top.equalTo(self.view).offset(rate750(539));
                make.height.equalTo(@(rate750(48)));
            }
        }];
        brokerButton.layer.cornerRadius = 4.0f;
        brokerButton.layer.masksToBounds = YES;
        [brokerButton addTarget:self action:@selector(brokerButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        _brokerButton = brokerButton;
    }
    return _brokerButton;
}

-(void)brokerButtonClick:(SYNoHeightedButton *)button
{
    DDLog(@"赚钱去吧")
    
    YDSendBrokerInformationController *vc = [[YDSendBrokerInformationController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
